package nbcp.http.api


import nbcp.http.HttpClient
import nbcp.http.annotation.*
import nbcp.http.model.NexusAssetsSearchResult
import nbcp.http.model.NexusComponentSearchResult
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty

@HttpClient("nexus")
interface NexusClient {

    @Get("/service/rest/v1/components")
    fun getComponents(
        @RequestHeader("Authorization") auth: String,
        @RequestParam("repository") repository: String,
        @RequestParam("continuationToken") continuationToken: String?
    ): NexusComponentSearchResult

    /**
     *
     * @see http://nexus.cloudnk.cn/service/rest/v1/search/assets?repository=maven-snapshots&maven.groupId=cn.dev8&maven.artifactId=ktbase&maven.baseVersion=1.1.6-SNAPSHOT&maven.extension=jar&maven.classifier=&sort=version&direction=desc
     */
    @Get("/service/rest/v1/search/assets")
    fun searchAssets(
        @RequestHeader("Authorization") auth: String,
        @RequestParam("repository") repository: String,
        @RequestParam("name") name: String?,
        @RequestParam("maven.groupId") groupId: String?,
        @RequestParam("maven.artifactId") artifactId: String?,
        @RequestParam("maven.baseVersion") baseVersion: String?,
        @RequestParam("maven.extension") extension: String?,
        @RequestParam("maven.classifier") classifier: String?,
        @RequestParam("sort") sort: String? = "version",
        @RequestParam("direction") direction: String? = "desc",
    ): NexusAssetsSearchResult
}